/*
 * @Description:游戏统计
 * @Author: maskMan
 * @LastEditTime: 2024-10-21 09:39:23
 */
import GamePanel from '../hall/gamePanel'
import { playEffect } from './shorts'
const { ccclass, property } = cc._decorator
@ccclass
export class GameStatis extends cc.Component {
  @property(cc.Label)
  scoreStr: cc.Label = null
  @property(cc.Label)
  costTimeStr: cc.Label = null
  @property(cc.Label)
  maxScoreStr: cc.Label = null
  @property(cc.Label)
  otherStr: cc.Label = null
  @property(cc.SpriteFrame)
  splist: cc.SpriteFrame[] = []
  @property(cc.Sprite)
  endsp: cc.Sprite = null
  scoreData: any
  onLoad() {
    this.maxScoreStr.string = this.scoreData.maxScore
    this.costTimeStr.string = this.scoreData.costTime
    this.scoreStr.string = this.scoreData.score
    this.otherStr.string = this.scoreData.otherData
    GamePanel.instance.currEndSc = this
    this._openAction()
  }
  /**打开动画 */
  private _openAction() {
    playEffect('shui')
    const rootNode = this.node.getChildByName('content')
    rootNode.active = true
    rootNode.x = 0
    rootNode.y = -812
    rootNode.runAction(cc.moveTo(0.5, 0, 0).easing(cc.easeBackOut()))
  }
  onRestart() {
    GamePanel.instance.currEndSc = null
    playEffect('btn')
    this.node.destroy()
    GamePanel.instance.onStartGame()
  }
  onRet() {
    GamePanel.instance.currEndSc = null
    playEffect('btn')
    this.node.destroy()
    GamePanel.instance.destroyGame(true)
  }
}
